package com.csdj.sc.provider.controller;


import com.csdj.sc.common.annonation.Role;
import com.csdj.sc.common.base.WebResult;
import com.csdj.sc.common.constant.RoleConstant;
import com.csdj.sc.common.constant.WebMsgConstant;
import com.csdj.sc.common.entity.User;
import com.csdj.sc.provider.service.IUserService;
import net.sf.jsqlparser.expression.MySQLGroupConcat;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author cloud
 * @since 2021-12-09
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private IUserService userService;

//    @GetMapping("/list")
//    @Role(roles = {RoleConstant.ROLE_ADMIN,RoleConstant.ROLE_MANAGER})
//    public WebResult getAllUsers(){
//        return new WebResult(WebMsgConstant.SUCCESS,userService.list());
//    }

    @GetMapping("/list")
    public List<User> getUsers(){
        return userService.list();
    }

    @GetMapping("/detail/{id}")
    public User getById(@PathVariable("id") int id){
        User byId = userService.getById(id);
        return byId;
    }

    @GetMapping("/detail")
    public User getByIds(@RequestParam("id") int id){
        User byId = userService.getById(id);
        return byId;
    }

    @PostMapping("/update")
    public User postUser(@RequestBody User user){
        User byId = userService.getById(user.getId());
        return byId;
    }



}

